package cn.vcjf.weapp.api.setting.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.vcjf.weapp.common.web.TableResult;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import cn.vcjf.weapp.api.setting.entity.LogisticsCompany;
import cn.vcjf.weapp.api.setting.service.LogisticsCompanyService;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhengzihang
 * @since 2018-09-25
 */
@Controller
@RequestMapping("/setting/logisticsCompany")
public class LogisticsCompanyController {
     @Resource
     private LogisticsCompanyService  logisticsCompanyService;

     @RequestMapping("/addLogisticsCompany")
     @ResponseBody
     public TableResult addLogisticsCompany(LogisticsCompany logisticsCompany){
         logisticsCompany.preInsert();
         boolean b = logisticsCompanyService.insert(logisticsCompany);
         return TableResult.Result(b);
     }

     @RequestMapping("/updateLogisticsCompany")
     @ResponseBody
     public TableResult updateLogisticsCompany(LogisticsCompany logisticsCompany){
         logisticsCompany.preUpdate();
        boolean b = logisticsCompanyService.updateById(logisticsCompany);
         return TableResult.Result(b);
     }

     @RequestMapping("/findLogisticsCompanyOne")
     @ResponseBody
     public TableResult findLogisticsCompanyOne(LogisticsCompany logisticsCompany){

        EntityWrapper<LogisticsCompany> wrapper = new EntityWrapper<LogisticsCompany>();

        if(logisticsCompany.getId()!=null){
            wrapper.eq("id",logisticsCompany.getId());
        }
        //Todo

        LogisticsCompany result = logisticsCompanyService.selectOne(wrapper);

		return TableResult.OKResult(result);
     }

     @RequestMapping("/findLogisticsCompanyList")
     @ResponseBody
     public TableResult findLogisticsCompanyList(LogisticsCompany logisticsCompany){

        EntityWrapper<LogisticsCompany> wrapper = new EntityWrapper<LogisticsCompany>();

		if(logisticsCompany.getId()!=null){
            wrapper.eq("id",logisticsCompany.getId());
        }
        //Todo

        Page<LogisticsCompany> page = logisticsCompany.getPageInfo();

        page = logisticsCompanyService.selectPage(page,wrapper);

		return TableResult.OKResult(page);

     }

     @RequestMapping("/deleteLogisticsCompany")
     @ResponseBody
     public TableResult deleteLogisticsCompany(LogisticsCompany logisticsCompany){
        logisticsCompany.preUpdate();
        boolean b = logisticsCompanyService.deleteById(logisticsCompany.getId());
        return TableResult.Result(b);
     }

}
